//
//  HSOrderDetailCell.m
//  hsdyOrderSystem
//
//  Created by XunFengKJ on 2017/11/14.
//  Copyright © 2017年 赖国锋. All rights reserved.
//

#import "HSOrderDetailCell.h"
#import "HSGuigeModel.h"
#import "HSFenliangModel.h"
@implementation HSOrderDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


-(void)setModel:(HSOrderModel *)model{
    _model = model;
//    for (HSOrderDetailModel *detailM in model.foodsList) {
//        shopCount = shopCount + [detailM.shopCount integerValue];
//        [self.imagesArr addObject:detailM.foodsImage];
//    }
    //一张时候
    HSOrderDetailModel *detailM = model.foodsList[0];
   
}

-(void)setDetailModel:(HSOrderDetailModel *)detailModel{
    [self.pictureImageView sd_setImageWithURL:[NSURL URLWithString:detailModel.foodsImage] placeholderImage:nil];
    self.nameL.text = detailModel.name;
    self.MoneyL.text =[NSString stringWithFormat:@"￥ %.2f",[self roundFloat:[[NSString stringWithFormat:@"%@",detailModel.price] floatValue]]];
    self.countL.text = [NSString stringWithFormat:@"x %@",detailModel.shopCount];
    
    
    NSString *guigeResultStr = @"";
    NSString *fengliangResultStr = @"";
    if (detailModel.kinds.count > 0) {
        
        for (int i = 0; i < detailModel.kinds.count; i ++) {
            HSGuigeModel *guigeM = detailModel.kinds[i];
            //拼接
            guigeResultStr = [guigeResultStr stringByAppendingString:[NSString stringWithFormat:@"%@,",[NSArray matchingStringWithDataArr:guigeM.names]]];
        }
        if (guigeResultStr.length>1) {
            guigeResultStr = [guigeResultStr substringToIndex:guigeResultStr.length-1];
        }
        //规格
        self.sizeL.text = [NSString stringWithFormat:@"规格：%@",guigeResultStr];
    }
    
    if (detailModel.prices.count > 0) {
        for (int i = 0; i < detailModel.prices.count; i ++) {
            HSFenliangModel *fengliangM = detailModel.prices[i];
            //拼接
            fengliangResultStr = [fengliangResultStr stringByAppendingString:[NSString stringWithFormat:@"%@,",fengliangM.name]];
        }
        if (fengliangResultStr.length>1) {
            fengliangResultStr = [fengliangResultStr substringToIndex:fengliangResultStr.length-1];
        }
        //份量
        self.fenliangL.text =[NSString stringWithFormat:@"份量：%@",fengliangResultStr];
    }
}


//除100区两位小数
-(float)roundFloat:(float)price{
    return  round(price * 100) / 10000;
}
@end
